package com.example.canvastest;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by 700 on 2018/7/30.
 */

public class DrawRoundRect extends View{

    private RectF rectf=new RectF(100, 100, 500, 500);
    private Paint paint ;

    public DrawRoundRect(Context context, AttributeSet attrs,
                           int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public DrawRoundRect(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public DrawRoundRect(Context context) {
        super(context);
    }

    private void initView(){
        paint = new Paint();
        paint.setColor(Color.BLUE);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        initView();
        canvas.drawRoundRect(rectf,10,10,paint);
    }
}
